using System;
using System.Collections.Generic;
using System.Text;

namespace Acms.DataControls
{
    public class UpdatingDataEventArgs<TItem> : System.EventArgs
    {
        public UpdatingDataEventArgs(TItem item, UpdateAction action, System.Collections.IDictionary keys, System.Collections.IDictionary values, System.Collections.IDictionary oldValues)
        {
            this.item = item;
            this.action = action;
            this.keys = keys;
            this.values = values;
            this.oldValues = oldValues;
        }

        private TItem item;
        public TItem Item
        {
            get { return item; }
        }

        private UpdateAction action;
        public UpdateAction Action
        {
            get { return action; }
        }

        private System.Collections.IDictionary keys;
        private System.Collections.IDictionary values;
        private System.Collections.IDictionary oldValues;

        public T GetKeyValue<T>(Enum key)
        {
            return GenericDataSource<TItem>.GetValue<T>(key, keys);
        }

        public T GetNewValue<T>(Enum key)
        {
            return GenericDataSource<TItem>.GetValue<T>(key, values);
        }

        public T GetOldValue<T>(Enum key)
        {
            return GenericDataSource<TItem>.GetValue<T>(key, oldValues);
        }

        public bool ValueChanged<T>(Enum key)
        {
            if (values == null || oldValues == null)
            {
                return false;
            }
            else
            {
                return GenericDataSource<TItem>.ValueChanged<T>(key, values, oldValues);
            }
        }
    }
}